package Coding.Th;

/**
 *
 * JVM启动后会自动创建一个main线程,用来执行main方法这个线程通常为"主线程"
 *
 * Thread 提供了一个静态方法,可以帮助我们获取执行该方法的线程对象
 * static Thread currentThread()
 * 
 */
public class CurrentThread {
    public static void main(String[] args) {

        Thread main = Thread.currentThread();
        System.out.println(main);

        Runnable r1 = new Runnable() {
            @Override
            public void run() {
                Thread t = Thread.currentThread();
                System.out.println(t);

            }
        };


        Thread t1 = new Thread(r1,"Thread1");
        Thread t2 = new Thread(r1,"Thread2");

        t1.start();
        t2.start();




    }
}
